class: center, middle, inverse, title-slide # CRS & Projections: Geographic vs Projected CRS --- layout: true <div class="dk-footer"> <span> <a href="https://rfortherestofus.com/" target="_blank">R for the Rest of Us </a> </span> </div> --- class: center, middle, dk-section-title, contain background-image:url("images/impossible-shapes.png") background-size: 80% # CRS & Projections: Geographic vs Projected CRS ??? --- ## All maps are wrong... .pull-left[ <iframe width="675" height="406" src="https://www.youtube.com/embed/kIID5FDi2JQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> ] .pull-right[ To squash the surface of the Earth onto a map we need to **project** from a sphere's surface to a 2D flat map. ] ??? --- ## Geographic CRS vs Projected CRS .pull-left[ **Geographic CRS** (including 4326) - Points are specified as longitudes and latitudes. - Distances are measured in non-physical units: degrees. ] -- .pull-right[ **Projected CRS** - Points are specified as (x, y) coordinates. - Distances are measured in **physical units**, e.g. metres. ] ??? --- ## Geographic CRS vs Projected CRS .pull-left[ **Geographic CRS** (including 4326) - Points are specified as longitudes and latitudes. - Distances are measured in non-physical units: degrees. Used for **visualisations**. ] .pull-right[ **Projected CRS** - Points are specified as (x, y) coordinates. - Distances are measured in **physical units**, e.g. metres. Used for **geometric calculations and GIS analysis**. ] ??? --- ### mapview needs a CRS to work .pull-left[ ```r quakes_no_crs <- quakes %>% st_as_sf(coords = c("long", "lat")) quakes_no_crs %>% mapview() ```
] .pull-right[ ```r quakes_4326_crs <- quakes %>% st_as_sf(coords = c("long", "lat"), * crs = 4326) quakes_4326_crs %>% mapview() ```
] ??? --- ### CRS codes are EPSG codes CRS 4326 is the **E**uropean **P**etroleum **S**urvey **G**roup (EPSG) code 4326. [EPSG.io](https://epsg.io) makes it simple to find EPSG codes. -- <br> > Unfortunately, not all CRS have an EPSG code ??? --- ## CRS vs WKT Only a small subset of possible Coorodinate Reference Systems *have* "CRS codes". The most general purpose and flexible way to refer to (and store) projections is in the **Well-Known Text (WKT)** representation. ??? --- ### WKT include all the complexity of GIS systems (I) .pull-left[ We're smoothing over a lot of complicated mathematics required to build CRS. The benefit of using WKT is that they can fully describe all of the details required for more complex GIS you or your colleagues might do in the future. ] .pull-right[ <img src='images/local-datums.gif' width='100%'/> Image credit: [desktop.arcgis.com/en/arcmap/10.3/guide-books/map-projections/datums](desktop.arcgis.com/en/arcmap/10.3/guide-books/map-projections/datums). ] --- ### WKT include all the complexity of GIS systems (II) .pull-left[ WKT can be recognised by the following features: - Most WKT examples you'll use begin with `GEODCRS` or `PROJCS`. - It contains nested square brackets ] .pull-right[ ```r GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]] ``` ] --- ### RStudio Coding Slide ??? --- ## Don't use geographic CRS for analysis .center[ <img src="data:image/png;base64,#01_12_crs-and-projections_geographic-vs-projected_files/figure-html/unnamed-chunk-7-1.png" height="400px" /> ] ??? --- ### Distance metrics are complicated in CRS 4326 .pull-left[ Distances between points in geographic CRS are measured in degrees of **longitude** and **latitude**. This globe shows the longitude lines (meridians) centred on the Prime Meridian in London. ] .pull-right[ <img src='images/longtude-latitudes-3d.png' width='80%'/> ] ??? --- ### Distance metrics are complicated in CRS 4326 .pull-left[ The distance between the longitude lines **varies** greatly dependent on how far points are away from the equator. - At the equator a degree of longitude is 111.32 km. - Moscow is at a latitude 55 where a degree of longitude is 62.64 km. ] .pull-right[ <img src='images/longtude-latitudes-3d.png' width='80%'/> ] .footnote[ For the mathematics behind these calculations [see here](https://en.wikipedia.org/wiki/Longitude#Length_of_a_degree_of_longitude). ] ??? --- ### Geographic CRS distort GIS operations .pull-left[ <img src='images/longtude-latitudes-3d.png' width='80%'/> ] .pull-right[ <img src="data:image/png;base64,#01_12_crs-and-projections_geographic-vs-projected_files/figure-html/unnamed-chunk-9-1.png" height="400px" /> ] ??? --- ### `{sf}` has your back .pull-left[ `{sf}` will warn you about misusing geographic CRS <img src='images/st-buffer-long-lat-warning.png'/> ] .pull-right[ `st_is_longlat()` will return TRUE for geographic CRS. ```r world_cities %>% st_is_longlat() ``` ``` ## [1] TRUE ``` ] ???